package yml

import (
	"io/ioutil"
	"fmt"
	"gopkg.in/yaml.v2"
)
var Config yamConfig
var Dir string

type yamConfig struct {
	Pid string `yaml:"pid"`
	AppPort string `yaml:"appport"`
	Mysql string `yaml:"mysql"`
	MysqlPing int `yaml:"mysqlping"`
	MysqlPrefix string `yaml:"mysqlprefix"`
	Redis string `yaml:"redis"`
	Auth Auth `yaml:"auth"`

}
type Auth struct {
	EnableTLS bool `yaml:"enabletls"`
	CAFile    string `yaml:"caffile"`
	CertFile  string `yaml:"certfile"`
	KeyFile   string `yaml:"keyfile"`
}

func GetConf(file string)  {
	println("conf:"+file)
	yamlFile, err := ioutil.ReadFile(file)
	if err != nil {
		fmt.Println("yamlFile.Get err   #%v ", err)
	}
	err = yaml.Unmarshal(yamlFile, &Config)
	if err != nil {
		fmt.Println("Unmarshal: %v", err)
	}
	fmt.Println("config:",Config)
}